//功能初始化函数
function loginInit(){
  let loginBtn = document.getElementById("login")
  let input = document.getElementById("username")
  loginBtn.addEventListener("click",handleLogin,false)
  //点击登录按钮事件
  function handleLogin(){
    let inputValue = input.value
    if(!inputValue || inputValue.trim().length < 6){
      alert("名称不得小于6个字符")
      input.value = ''
      return
    }
    localStorage.setItem("username",inputValue)
    location.href = "index.html"
  }
}

loginInit()